<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./../../WEB-INF/templates/noFooterCandidateTemplate.xhtml">
            <ui:define name="content">
               
                    
                <h:form id="notificationsCandidateViewForm">
                    <p:dialog id="notificationDialog" widgetVar="notificationDialog" resizable="false"  
                              showEffect="fade" hideEffect="fade" header="#{messages.Notification}">  

                        <h:panelGrid id="display" >  
                            <h:outputText value="#{notificationsUserBean.chosenEntity.description}" />  
                        </h:panelGrid>  
                    </p:dialog> 
                    <p:growl id="growl"/>
                    <p:toolbarGroup align="left">  
                        <p:commandButton id="markAsViewAllNotifications"  value="#{messages.MarkAsViewAll}" update="notificationsCandidateViewForm:notificationsDatatable :barForm:tabMenuPanel" actionListener="#{notificationsUserBean.markAllNotificationsAsView()}"/>  
                    </p:toolbarGroup>
                    <p:panel id="notificationsDatatable" styleClass="noBorder noPadding noMargin">
                        <p:dataTable   var="notification" value="#{notificationsUserBean.entityList}" rowKey="#{notification.idNotification}" 
                                      paginator="true" rows="50"  
                                      rowStyleClass="#{notification.isNotificated == false ? 'notificationNew' : 'notificationOld'}"
                                      selection="#{notificationsUserBean.chosenEntity}" selectionMode="single">  
                           
                            <p:ajax event="rowSelect" listener="#{notificationsUserBean.notificationRead()}"   
                                    update=":notificationsCandidateViewForm:notificationDialog :notificationsCandidateViewForm:notificationsDatatable :barForm:tabMenuPanel"  oncomplete="notificationDialog.show();" />
                            <p:column headerText="#{messages.Notifications}"  >  
                                <h:outputText  value="#{notification.description}" />  

                            </p:column>  

                            <!--<p:column id="date" sortBy="#{notification.date}" headerText="#{messages.Date}">  
                                <h:outputText value="#{notification.date}">
                                    <f:convertDateTime pattern="d/M/yyyy - HH:mm"></f:convertDateTime>
                                </h:outputText>
                            </p:column> -->
                            
                        </p:dataTable>  
                    </p:panel>
                    
                    
                </h:form>
                <h:form>
                    <p:socket onMessage="handleMessageNt" channel="/notification/#{editCandidateBean.candidate.user.idUser}"/>  
                    <p:remoteCommand async="true" name="ntCommand"  update=":notificationsCandidateViewForm:notificationsDatatable" ></p:remoteCommand>
                <script type="text/javascript">  
                    function handleMessageNt(notificationData) {
                        ntCommand([{name: 'idNotification', value: notificationData}]);
                    }  
                </script>  
                </h:form>
                
            </ui:define>
        </ui:composition>

    </body>
</html>

